﻿using Microsoft.AspNetCore.Mvc.Filters;
using System;
using System.Collections.Generic;
using System.Text;
using WepApi07.Data.Entity;
using WepApi07.Domain;
using WepApi07.Intenface.Log;
using WepApi07.Util.Log;

namespace WepApi07.Util.Filters
{

    public class GlobalExceptionFilter:IExceptionFilter
    {
        private readonly IResponsitory<Logs> _log;

        public GlobalExceptionFilter(IResponsitory<Logs> log)
        {
            _log = log;
        }
        public void OnException(ExceptionContext context)
        {
            _log.Fatal(context.Exception);

            _log.Insert(new Logs
            {

            });

            context.ExceptionHandled = true;
        }
    }
}
